package com.TestDemo.Test202203To04;

import java.io.BufferedReader;
import java.io.InputStreamReader;

/**
 * Created with IntelliJ IDEA.
 *
 * @Author: zjz
 * @Date: 2022/06/07/8:33
 * @Description:
 * @Target:
 */
public class juzhen90du {
    public static void main(String[] args) throws Exception{
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        // 矩阵输入n，变为二维矩阵
        int n = Integer.valueOf(in.readLine());
        int[][] ints1 = new int[n][n];
        int[][] ints2 = new int[n][n];
        int index = 1;
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                ints1[i][j] = index++;
            }
        }

        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                ints2[i][j] = ints1[n-j-1][i];
            }
        }

        System.out.println("初始化矩阵：");
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                System.out.print(ints1[i][j]+" ");
            }
            System.out.println();
        }

        System.out.println("改完的：");

        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                System.out.print(ints2[i][j]+" ");
            }
            System.out.println();
        }


    }
}
